package com.ke.hbasetohdfs;

import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapper;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;


import java.io.IOException;

public class MyMapper extends TableMapper<Text, IntWritable> {

    public static final byte[] CF = "cf".getBytes();
    public static final byte[] ATTR1 = "name".getBytes();

    private final static IntWritable one = new IntWritable(1);
    private Text word = new Text();

    @Override
    protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException {

        System.out.println("MyMapper -key -" + key);
        System.out.println("MyMapper -value -" + value);
        System.out.println("MyMapper -context -" + context);
        String val = new String(value.getValue(CF, ATTR1));

        word.set(val.toString());
        context.write(word, one);
    }

}
